import 'package:flutter/material.dart';
class CounterHome extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
      CounterBloc _counterBloc = CounterPorvider.of(context).counterBloc;
    return Center(
      child: ActionChip(
        label: Text('0'),
        onPressed: (){
          _counterBloc.log();
        },
      ),
    );
  }
}

class CounterActionButton extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    CounterBloc bloc = CounterPorvider.of(context).counterBloc;
    return FloatingActionButton(
      child: Icon(Icons.add),
      onPressed: (){
        bloc.log();
      },
    );
  }
}

class CounterPorvider extends InheritedWidget {
  CounterPorvider({Key key, this.child,this.counterBloc}) : super(key: key, child: child);

  final Widget child;
  final CounterBloc counterBloc;
  static CounterPorvider of(BuildContext context) {
    return (context.inheritFromWidgetOfExactType(CounterPorvider)as CounterPorvider);
  }

  @override
  bool updateShouldNotify( CounterPorvider oldWidget) {
    return true;
  }
}


class CounterBloc{
  void log(){
    print('CounterBloc');
  }
}
